#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cstdlib>
#include <unistd.h>
#include <cerrno>
#include <string>

using namespace std;

const char* pipePath = "./myPipe";

int main()
{
    int fd = open(pipePath,O_RDONLY);
    if(fd == -1)
    {
        perror("open");
        exit(1);
    }
    char buf[1024];
    ssize_t t = read(fd,buf,sizeof(buf)-1);
    if(t == -1)
    {
        perror("read");
        close(fd);
        exit(1);
    }
    buf[t] = '\0';
    cout<<"received message:"<<buf;
    close(fd);
    return 0;
}